DevForce Help Reference
Start(Func<CoroutineOperation,IEnumerable<Func<INotifyCompleted>>>,Action<CoroutineOperation>) Method
Example 


List of asynchronous functions
Optional completion handle
Start serial execution of multiple asynchronous actions.
Syntax

Parameters

asyncFns
List of asynchronous functions
completedHandler
Optional completion handle

Return Value

A CoroutineOperation representing this operation
Remarks
Used to start serial execution of a list of asynchronous actions. Instead of passing an iterator block, pass an IEnumerable of the asynchronous functions to be executed. Asynchronous functions in the list will be executed serially.

Use this overload of the Start method when your iterator accepts a CoroutineOperation as an argument. You can use the CoroutineOperation to track the prior operations within the function list.

This overload of the Start method is useful in Visual Basic, where iterators are not supported.

Example
Public Sub CoroutineSample4()
    Dim mgr = New NorthwindIBEntities()
    Dim op = Coroutine.Start(Function(coop As CoroutineOperation) Sample3Actions(coop, mgr))
    AddHandler op.Completed, Sub(s As Object, e As CoroutineCompletedEventArgs)
                                 If e.CompletedSuccessfully Then
                                     MessageBox.Show("OK")
                                 End If
                             End Sub
End Sub

Private Function Sample3Actions(ByVal coop As CoroutineOperation, ByVal mgr As NorthwindIBEntities) As IEnumerable(Of Func(Of INotifyCompleted))
    ' Setup of the list of async functions for the Coroutine to execute serially.
    Dim operationList = New List(Of Func(Of INotifyCompleted))

    Dim f1 As Func(Of INotifyCompleted) = Function() mgr.Customers.Take(2).ExecuteAsync()
    operationList.Add(f1)

    Dim f2 As Func(Of INotifyCompleted) =
         Function()
             ' Use the results from the first async query. 
             Dim firstOp = DirectCast(coop.Notifications.First(), EntityQueryOperation(Of Customer))
             Dim customers = firstOp.Results
             Dim cityList = New List(Of String)
             customers.ForEach(Sub(cust As Customer) cityList.Add(cust.City))
             Dim pd = New IdeaBlade.Linq.PredicateDescription(GetType(Order), "Shipcity", IdeaBlade.Linq.FilterOperator.InList, cityList)
             Return mgr.Orders.Where(pd).ExecuteAsync()
         End Function
    operationList.Add(f2)

    Return operationList
End Function
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Coroutine Class
Coroutine Members
Overload List

Send Feedback